package com.itheima.d4_algorithm;

import java.util.Arrays;

/**
 * 目标：掌握选择排序。
 */
public class Test2 {
    public static void main(String[] args) {
        int[] arr = {8, 5, 2, 1, 7, 9, 6};
        xianzhong(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void xianzhong(int[] arr) {
        int a;
        for (int j = 0; j < arr.length - 1; j++) {
            for (int i = 1 + j; i < arr.length; i++) {
                if (arr[j] > arr[i]) {
                    a = arr[i];
                    arr[i] = arr[j];
                    arr[j] = a;
                }
            }
        }
    }
}
